using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using SurveyHost.Core;
using SurveyHost.Core.DAL;

namespace SurveyHost.Web.Controls
{
    public partial class Paragraph : System.Web.UI.UserControl
    {
        private string _contentName;
        private string _contentText = "";
        /// <summary>
        /// The name of the paragraph content
        /// </summary>
        public string ContentName
        {
            get { return _contentName; }
            set { _contentName = value; }
        }

        /// <summary>
        /// The text of the paragraph
        /// </summary>
        protected string ContentText
        {
            get { return _contentText; }
            set { _contentText = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(ContentName))
            {
                Content text = new Content(Content.Columns.ContentName, ContentName);
                if (text.IsLoaded && !string.IsNullOrEmpty(text.Body.Trim()))
                {
                    _contentText = text.Body.Replace(Environment.NewLine,"<br/>");
                }
            }
            else
            {
                _contentText = "Please set the ContentName on this control to a unique name.";
            }
        }
    }
}